package com.jiazixuan.stock.config;

import com.jiazixuan.stock.pojo.vo.StockInfoConfig;
import com.jiazixuan.stock.utils.IdWorker;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;


@Configuration
@EnableConfigurationProperties({StockInfoConfig.class})
public class CommonConfig {
//    /**
//     * 密码加密器
//     * BCryptPasswordEncoder方法采用SHA-256对密码进行加密
//     * @return
//     */
//    @Bean
//    public PasswordEncoder passwordEncoder(){
//        return new BCryptPasswordEncoder();
//    }
    /*
    * 基于雪花算法保证生成的id唯一
    * */
    @Bean
    public IdWorker idWorker(){
        /**
         * 参数1：机器ID
         * 参数2：机房ID
         * 机房和机器编号一般是运维人员进行唯一性规划
         */
        return new IdWorker(1l,2l);
    }

}
